package com.heny.demo;

import com.heny.demo.entity.TurnPoint;
import com.heny.demo.service.FileImportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@RestController
public class TurnPointController {

    @Autowired
    private FileImportService fileImportService;

    @PostMapping("/upload")
    public Boolean uploadTurnPoint(@RequestParam("turnPointFile") MultipartFile turnPointFile) {
        try {
            List<TurnPoint> turnPoints = fileImportService.importFile(turnPointFile);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }
}